function[SSPM] = sortspm(SPM),

nsp = length(SPM.spectra);

for i = 1:nsp,
    frq(i) = SPM.spectra(i).freq;
end;

[Y,I] =sort(frq);

for i = 1:nsp,
    SSPM.spectra(I(i)) = SPM.spectra(i);
end;


